﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QCCure
{
    public partial class FormPrompt : Form
    {
        public FormPrompt()
        {
            InitializeComponent();
        }

        public static string Show(string label)
        {
            return Show(label, label, null);
        }

        public static string Show(string label, string caption)
        {
            return Show(label, caption, null);
        }

        public static string Show(string label, string caption, string defaultValue)
        {
            FormPrompt prompt = new FormPrompt();
            prompt.Label = label;
            prompt.Caption = caption;
            prompt.Value = defaultValue;

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                return prompt.Value;
            }
            else
            {
                return null;
            }
        }

        public string Label
        {
            get
            {
                return this.textInput.Text;
            }
            set
            {
                this.textInput.Text = value;
            }
        }

        public string Caption
        {
            get
            {
                return this.Text;
            }
            set
            {
                this.Text = value;
            }
        }

        public string Value
        {
            get
            {
                return this.textInput.Text;
            }
            set
            {
                this.textInput.Text = value;
            }
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Hide();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Hide();
        }
    }
}
